/**
 * Copyleft (C) 2023-2024 maminjie <canpool@163.com>
 * SPDX-License-Identifier: BSD-3-Clause
 **/
#ifndef QXMATERIALPROGRESS_P_H
#define QXMATERIALPROGRESS_P_H

#include "qxmaterial_global.h"
#include "matprogress.h"
#include <QColor>
#include <QObject>

QX_MATERIAL_BEGIN_NAMESPACE

class MatProgress;
class MatProgressDelegate;

class MatProgressPrivate
{
    Q_DISABLE_COPY(MatProgressPrivate)
    Q_DECLARE_PUBLIC(MatProgress)
public:
    MatProgressPrivate(MatProgress *q);
    ~MatProgressPrivate();

    void init();

    MatProgress *const q_ptr;
    MatProgressDelegate *delegate;
    Material::ProgressType progressType;
    QColor progressColor;
    QColor backgroundColor;
    bool useThemeColors;
};

class MatProgressDelegate : public QObject
{
    Q_OBJECT

    Q_PROPERTY(qreal offset WRITE setOffset READ offset)
public:
    MatProgressDelegate(MatProgress *parent);
    ~MatProgressDelegate();

    inline void setOffset(qreal offset);
    inline qreal offset() const;
private:
    Q_DISABLE_COPY(MatProgressDelegate)

    MatProgress *const m_progress;
    qreal m_offset;
};

inline void MatProgressDelegate::setOffset(qreal offset)
{
    m_offset = offset;
    m_progress->update();
}

inline qreal MatProgressDelegate::offset() const
{
    return m_offset;
}

QX_MATERIAL_END_NAMESPACE

#endif   // QXMATERIALPROGRESS_P_H
